const download = (url: string, title: string, artist: string) => {
  console.log('hhhhhhhhhh', title);

  var x = new XMLHttpRequest();
  x.open('GET', url, true);
  x.responseType = 'blob';
  x.onload = function () {
    const url = window.URL.createObjectURL(x.response);
    const eleLink = document.createElement('a');
    eleLink.href = url;
    if(artist==''){
      eleLink.download = title;
    }else{
      eleLink.download = `${title} - ${artist}`;
    }
    
    eleLink.style.display = 'none';
    document.body.appendChild(eleLink);
    eleLink.click();
    document.body.removeChild(eleLink);
  };
  x.send();
};
export default download;
